package com.deng.heney.common;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

/**
 * @description: 封装json文件
 * @author: dengmeng
 * @date: 2024/9/7 10:57
 */
@Data
@AllArgsConstructor
@Builder
public class Result {
    public static final String CODE_SUCCESS = "200";
    public static final String CODE_AUTH_ERROR = "401";
    public static final String CODE_SYS_ERROR = "500";

    public String code;
    public String msg;
    public Object data;

    public static Result suceess() {
//        return new Result(CODE_SUCCESS,"请求成功",null);
        //构建者模式
        return Result.builder().code(CODE_SUCCESS).msg("请求成功").build();
    }

    public static Result suceess(Object data) {
        return new Result(CODE_SUCCESS,"请求成功",data);
    }

    public static Result error(String msg) {
        return new Result(CODE_SYS_ERROR,msg,null);
    }

    public static Result error(String code, String msg) {
        return new Result(code, msg, null);
    }

    public static Result error() {
        return new Result(CODE_SYS_ERROR, "系统错误", null);
    }

}
